package com.arges.demo;

import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;

/**
 * <p>
 * TODO
 * </p>
 *
 * @author fanweitao
 * @date 2023/02/24
 */
public class CpuWin {

    public static void main(String[] args) {
        OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
        double cpuUsage = osBean.getSystemLoadAverage() * 100;
        double cpu2 = osBean.getAvailableProcessors() * 100;
        System.out.println("CPU使用率：" + cpuUsage);
        System.out.println("CPU使用率：" + cpu2);
    }


}

